#region license
# This file is part of Grawlix.
# 
# Grawlix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# 
# Grawlix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with Grawlix.  If not, see
# <http://www.gnu.org/licenses/>.
#endregion

"""Interface abstracting rendering operations."""

namespace Grawlix.Services.Rendering
import Grawlix
import System
import System.Drawing.Color as Color

interface IRenderDevice:
"""Service providing rendering operations."""
	
	def LoadTexture(image as Image) as ITextureState
	"""
	Load the specified bitmap into a texture, getting an instance of texture data.
	Param image: The image to load.
	Returns: The texture state data that can be used to render.
	Remarks: This is an advanced operation.
		Use <Services.Rendering.TextureResource>.
	"""
	
	def LoadFont(font as Drawing.Font) as IFontState
	"""
	Load the specified font into the engine, getting an instance of FontData.
	Param font: The font to load.
	Returns: The font state data that can be used to render.
	Remarks: This is an advanced operation.
		Use <Services.Rendering.FontResource>.
	"""
	
	def UnloadTexture(texture as ITextureState)
	"""
	Unloads the specified texture object.
	Param texture: The texture data, originally returned by LoadTexture.
	Raises ArgumentException: texture is not a loaded texture object.
	Remarks: This is an advanced operation.
		Use <Services.Rendering.TextureResource>.
	"""
	
	def UnloadFont(font as IFontState)
	"""
	Unloads the specified font object.
	Param font: The font data, originally returned by LoadFont.
	Raises ArgumentException: font is not a loaded font object.
	Remarks: This is an advanced operation.
		Use <Services.Rendering.FontResource>.
	"""
	
	def Resize(dimensions as Vector)
	"""
	Resize the viewport.
	Param dimensions: The new dimensions of the viewport.
	Remarks: For front-end use only.
	"""
	
	def Clear()
	"""
	Clear the screen and set up view state.
	Remarks: Call once every frame before rendering.
		For front-end use only.
	"""
	
	def Finish()
	"""
	Wait for all rendering commands to be processed.
	Remarks: Call once every frame after rendering.
		For front-end use only.
	"""
	
	def DrawRectangle(color as Color, target as Rect)
	"""
	Draw a rectangle on the current context.
	Param color: The color to render.
	Param target: The rectangle to render.
	"""
	
	def DrawTexture(
		texture as ITextureState,
		source as Rect,
		tint as Color,
		target as Rect)
	"""
	Draw a textured on the current context.
	Param texture: The data of the texture to render, loaded by this renderer.
	Param source: The rectangle within the texture to render.
	Param tint: The color to tint the rectangle.
	Param target: The rectangle on the screen to render.
	Raises ArgumentException: texture was not created by
		this device or has been unloaded.
	"""
	
	def DrawText(
		runs as TextRun*,
		origin as Vector)
	"""
	Render text in a box on the screen.
	Param runs: The text to render.
	Param origin: An origin point relative to the glyph locations.
	Raises ArgumentException: The font of a run was not created by
		this device or has been unloaded.
	"""
	
	def Clip(area as Rect) as IDisposable
	"""
	Clip to the specified area.
	Returns: An object used to undo the operation.
		Put it in a using block.
	"""
	
	def Zoom(source as Rect, scale as Rect) as IDisposable
	"""
	Change the view perspective, clipping to the new screen.
	Param source: The rectangle to scale and clip to, in
		old coordinates.
	Param scale: The new coordinates of the screen.
	Returns: An object used to undo the operation.
		Put it in a using block.
	"""
	
